package com.jt;

import org.springframework.beans.factory.annotation.Value;
import org.springframework.boot.SpringApplication;
import org.springframework.boot.autoconfigure.SpringBootApplication;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RestController;

/**
 * @author SWJ
 * @create 2021-08-16 17:04
 */
@SpringBootApplication
public class ProviderApplication {
    public static void main(String[] args) {
        SpringApplication.run(ProviderApplication.class, args);
    }

    /**
     * 创建启动类，并定义处理请求的控制层对象和方法，
     */

    @Value("${server.port}")
    private String server;
    /**@Value（8080口）*/
    // 获取端口号//http://localhost:8081/provider/echo/msa

    /**
     * 定义Controller对象(对象在spring mvc中给他定义的handler)
     * 基于对象处理客户的要求
     */
    @RestController
    //先写对象在写注释
    public class ProviderController {
        //http://localhost:8081/provider/echo/msa
        @GetMapping(value = "/provider/echo/{msg}")
        //restful表达式
        public String doEcho(@PathVariable String msg) {
            return server + "say:Hello Nacos Discovery " + msg;
        }
    }

}
